package com.es.gateway.一砂云.港澳台公民实人二要素校验;

import com.es.gateway.sdk.ESGateway;
import com.es.gateway.sdk.app.identity_auth_2.IdentityAuth2Request;
import com.es.gateway.sdk.app.identity_auth_2.IdentityAuth2Response;
import com.es.gateway.sdk.constant.AlgorithmE;
import com.es.gateway.sdk.entity.GatewayResponse;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

/**
 * 非大陆公民实人二要素校验, 参考
 */
@Slf4j
public class IdentityAuthTester {
    /**
     * 港澳台公民实名二要素: https://esandinfo.yuque.com/yv6e1k/aa4qsg/phh4ey
     */
    @Test
    public void test() {
        String appCode = "d2808c1338ce01f3e3efdb486f9effb9";
        AlgorithmE algo = AlgorithmE.MD5;
        String key = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEhdQdw6uTGz+X4e+/eGpu4dcKrfrjQAe0tTQyn6TuKBobcsUsESkx9jcCeG4cpuxmN8jNeDAZsbTujNLD/aYl2g==";
        ESGateway esGateway = new ESGateway(appCode, algo, key);

        IdentityAuth2Request request = new IdentityAuth2Request();
        request.setNation("CHN");
        request.setIdType("3");
        request.setName("李晨");
        request.setIdNO("H60511121");
        GatewayResponse gatewayResponse = esGateway.sendToGateWay(IdentityAuth2Request.act, request.toJsonStr());
        log.info("服务器端返回: {}", gatewayResponse.toJsonStr());
        if (gatewayResponse.getBizContent() != null) {
            log.info("数据验签结果: {}", gatewayResponse.isSignVerifyResult());
            IdentityAuth2Response response = IdentityAuth2Response.fromJsonStr(gatewayResponse.getBizContent());
            log.info("业务数据为: {}", response.toJsonStr());
        }
    }
}
